﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SchoolData : ImplData
{

    private Dictionary<string, Dictionary<string, List<string>>> d = new Dictionary<string, Dictionary<string, List<string>>>();

    protected override int Deserialize()
    {

        if (string.IsNullOrEmpty(jsonText))
            return -1;

        data = MiniJSON.Json.Deserialize(jsonText) as Dictionary<string, object>;

        foreach (var item in data)
        {
            Dictionary<string, object> dict = item.Value as Dictionary<string, object>;
            string province = item.Key;

            Dictionary<string, List<string>> dd = new Dictionary<string, List<string>>();
            foreach ( var i in dict )
            {
                string city = i.Key;
                List<object> schools = i.Value as List<object>;
                List<string> temp = new List<string>();
                foreach(var iiii in schools)
                {
                    temp.Add(iiii.ToString());
                }
                dd.Add(city, temp);
            }

            d.Add(province, dd);

        }

        return 0;
    }

    public List<string> GetAllProvince()
    {
        List<string> l = new List<string>();
        foreach( var item in d)
        {
            foreach( var i in item.Value )
            {
                foreach( var ii in i.Value)
                {
                    l.Add(item.Key + "," + i.Key + "," + ii);
                }
            }
        }

        return l;
    }

    
}

